[2.0.x] Macro G-codes#9365
Conversation
|
Just because I'm curious: Wouldn't it be easier in your case to use slicers gcode on tool change section? |
|
@Sebastianv650 I did exactly that so far. But let me add two more pieces for the complete picture. First, my printer has interchangeable hotends, and a E3D Volcano requires a different material change procedure than a regular E3D hotend. Second, there is a post-processing script involved which adds all the required purge tower stuff to the g code generated by slic3r. The script does automatic placement of the towers and I want the tool change to happen at the position of the purge towers. So far I used self-defined placeholders in the slic3r tool change g-codes which were replaced by the post-processing script with the coordinates of the purge towers. But this way the script has to scan lots of g code lines for the placeholders to replace them. To fasten things up I decided to have the script handle the complete tool change/purge tower procedure. That's where the g-code macro idea came into play because this way the script just places a single M810 when the material change should happen. What M810 means for the current print is defined in the slic3r start g-code section. Maybe this macro stuff is complete nonsense, and I'm not sure it's a general purpose feature for Marlin, either. But it's implemented now, so if anyone has use for it, there you go. |
e925eb0 to
934a03c
Compare
|
Hmm, I see that actually this cannot work without further additions. First of all, if you use If, as I attempted to do, you instead use The correct way to deal with multiple commands is to use So, in order to support this feature, the G-code core parser would need to be extended with an additional variable ( |
|
@thinkyhead thank you for the feedback. I'll have a look at And I understand from your changes that configuration for this kind of feature should be placed into |
|
Most new options should go in |
6534523 to
779001c
Compare
|
@revilor I've finished this up but haven't yet given it a test run. Have a look at your earliest convenience. If it works as-advertised then it can get merged soon. |
|
@thinkyhead I've been working on more complex extension of the command queue. To not mix it up with this PR I created a separate PR #9479. I can of course also integrate my queue extensions into this PR in case you prefer it that way. |
|
@thinkyhead Thank you for your latest additions to this PR, everything works fine for me. Feel free to merge and deal with PR #9479 independently. |
Let's keep that separate. It needs to be more carefully considered. We have very limited SRAM to use, and the current PSTR-based method works well to keep RAM use low. A "command stack" is going to involve another large, persistent buffer, which never makes us happy. Obviously for 1284p with its generous 16K or SRAM, no problem. But most of us are still using Mega2560, and are already very close to limits. Use |
422fe87 to
8916532
Compare
8b99060 to
a01473d
Compare
2308508 to
1e946d6
Compare
f454bf2 to
63f4c9b
Compare
0226dcc to
834ea7f
Compare
9fb4e95 to
ad12b9b
Compare
5f6db62 to
d0c96ee
Compare
9d867f9 to
849dea9
Compare
579c7f3 to
d52deeb
Compare
|
I have most of my printers are tuned very similar and can use the same print profile other than the start and stop g-code. I have been toying with the idea to have the start and end g-code of each of my printers embedded in the machine/firmware. This may be a good use case for this pull request. I could embed M810 in my start script and M811 for my stop script. This would make my sliced g-code universal across all my printers similar to tool paths for CNC. |
8a7664f to
5d487ef
Compare
19bb675 to
68f03dc
Compare
68f03dc to
7d900b3
Compare
|
I've rebased this and updated the code to use the Also:
To obtain the updated code in your working copy… |
7d900b3 to
4bb96af
Compare
This PR adds g codes M810 to M819 which allow to define g code macros.
Example usage:
Define macro 0
M810 G1 X0 Y0 Z0 F200|G4 S10|G1 X10 Y10 Z10
Use macro 0
M810
will enqueue the g code commands
G1 X0 Y0 Z0 F200
G4 S10
G1 X10 Y10 Z10
Background: for my multi-material setup based on a Prusa stepper multiplexer and a self-designed 4x Y-Splitter I needed material change procedures which are more complex than what M701 and M702 provides. As it is a very specific requirement for my setup it makes no sense to extend M701 and M702 accordingly. Instead I added a way to create macros which may be a useful feature for other Marlin users and different use cases, too.